<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});

Route::group([
    'prefix' => 'admin',
    'namespace' => 'App\Http\Controllers\Admin',
], function () {
    // 后台用户路由
    Route::group([
        'prefix' => 'admin/user',
    ], function () {
        // 后台用户注册
        Route::post('/register', 'AdminUserController@register');

        // 后台用户登陆
        Route::post('/login', 'AdminUserController@login');

        // 需要认证的路由
        Route::group([
            'middleware' => ['auth:admin_api'],
        ], function () {
            // 后台用户列表
            Route::get('/index', 'AdminUserController@index');

            // 后台用户列表
            Route::post('/logout', 'AdminUserController@logout');

            // 后台用户详情
            Route::get('/{id}', 'AdminUserController@show');;
        });

    });


});
